#!/usr/bin/env python
import random
import math
class dicethrow(object):
    def throw(self, num): #Generates the dice throws
        dice = []
        roll = 0
        x = 0
        while(x < num):
            roll = random.randint(1,6)
            dice.append(roll)
            x += 1
        return dice
    def htest(self, dice): #Counts number of fives or sixes
        num = len(dice) #Gets the total number of dice rolled
        hits = 0
        for throw in range(num):
        	if dice[throw] > 4: hits += 1
        return hits
    def gtest(self, dice): #Determines if glitch occurs
        num = len(dice) #Gets the total number of dice rolled
        glct = 0 #number of ones
        glit = False
        #glitch threshold
        threh = int(math.ceil(num/2.0)) #Threshold is half total dice rounded up
        for throw in range(num):
            if dice[throw] == 1: glct += 1
        if glct >= threh:
            glit = True #If number of ones greater than threshold glitch occurs
        return glit
    def ctest(self, hits): #Determines if glitch critical
        crit = False
        if hits == 0: crit = True
        return crit
